import db from "./db";
import mydate from "./mydate";

async function giveAlert(){
	console.log("执行giveAlert")
	plus.push.clear();
	let num = 0,aim=[]
	let eventList = await db.selectEvent();
	console.log("输出数据",eventList);
	let today = mydate.todayString();
	for(let i in eventList)
	{
		eventList[i].remain = mydate.dayComputed(today,eventList[i].end);
		if(eventList[i].remain <= 3)
		{
			num++;
			aim.push(eventList[i].name);
		}
	}
	if(num!=0)
	{
		plus.push.createMessage(`有${num}个事件将结束。\n将要事件有：${aim}`,`${aim}`);
	}
}

export default {
	giveAlert:giveAlert, 	// 开启提示
};